import common from "@/validator/common";

const name = [
  common.getRequiredRule('课程名'),
  {
    type: 'string',
    min: 2,
    max: 40,
    message: '课程名需在2 - 30个字符之间'
  }
]

const hours = [
  common.getRequiredRule('总学时'),
  ...common.getPositiveIntegerRules('总学时')
]

const type = [
  common.getRequiredRule('课程类别'),
]

const sumNumber = [
  common.getRequiredRule('课程人数'),
  ...common.getPositiveIntegerRules('课程人数')
]

/*const sumClass = [
  common.getRequiredRule('开设班数'),
  ...common.getPositiveIntegerRules('开设班数')
]*/

const deptId = [
  common.getRequiredRule('所属院系')
]

const teacherId = [
  common.getRequiredRule('授课教师')
]

const credit = [
  common.getRequiredRule('课程学分'),
  {
    type: 'number',
    message: '课程学分只能为数字'
  }
]

const year = [
  common.getRequiredRule('所属学年'),
  ...common.getPositiveIntegerRules('所属学年')
]

const semester = [
  common.getRequiredRule('所属学期'),
  ...common.getPositiveIntegerRules('所属学期')
]

const status = [
  common.getRequiredRule('课程状态'),
  ...common.getPositiveIntegerRules('课程状态')
]

const classId = [
  common.getRequiredRule('所属班级')
]

export default {
  insertRules: {
    name,
    hours,
    type,
    sumNumber,
    // sumClass,
    deptId,
    teacherId,
    classId,
    credit,
    year,
    semester,
    status
  },
  updateRules: {
    name,
    hours,
    type,
    sumNumber,
    // sumClass,
    deptId,
    teacherId,
    classId,
    credit,
    year,
    semester,
    status
  }
}
